#!/bin/bash
#2017年5月24日20:21:09
#by jfedu.net
#auto deploy tomcat for jenkins war.
###############
TOMCAT_DIR="/usr/local/tomcat_app/"
APP_WAR="edu.war"
BACK_DIR="/data/backup/`date +%Y%m%d`"
#TOMCAT_PID=`ps -ef |grep java|grep -v grep |grep -v auto|awk '{print $2}'`
TOMCAT_PID=`lsof -i :7002|awk '{print $2}'|grep -v PID`
source /etc/profile
###############
if [ ! -d $BACK_DIR ];then
	mkdir -p $BACK_DIR
fi
cd $TOMCAT_DIR/webapps/ROOT/
\cp *  $BACK_DIR -a
##############
kill -9 $TOMCAT_PID
rm   -rf  $APP_WAR  $TOMCAT_DIR/work/*
wget -c   http://bbs.jfedu.net/download/$APP_WAR
touch $APP_WAR
#jar  -xvf $APP_WAR
echo "/bin/sh $TOMCAT_DIR/bin/startup.sh---------------------------"
/bin/sh $TOMCAT_DIR/bin/startup.sh
echo "--------------------------------done"
tail -n 30 $TOMCAT_DIR/logs/catalina.out 
jar  -xvf $APP_WAR
